<template>
  <div class="label-count" style="flex:1">
    <div class="label-count-icon">
      <img :src="info.icon" alt="" />
    </div>

    <div class="label-count-detail">
      <div class="value-box">
        <span class="value">{{ val }}</span>
        <span class="unit">
          <slot name="unit">{{ info.unit }}</slot>
        </span>
      </div>
      <div class="label">
        <slot name="label">
          <span>{{ info.label }}</span>
        </slot>
      </div>
    </div>
  </div>
</template>

<script setup>
import { numberFormat } from "@/utils";
import { computed } from "vue";

const props = defineProps({
  info: {
    type: Object,
    default: () => {},
  },
});

const val = computed(() => {
  const format = `${props.info.value} || 0`.includes(".")
    ? "1,000.00"
    : "1,000";
  return props.info?.isString ? props.info.value : numberFormat(props.info.value || 0, format);
});
</script>

<style lang="scss" scoped>
.label-count {
  display: flex;
  align-items: center;
  color: #ffffff;
  &-icon {
    width: 100px;
    height: 100px;
    margin-right: 10px;
    padding-top: 10px;
    box-sizing: border-box;
    position: relative;
    // background-color: rgba($color: pink, $alpha: 0.3);
    overflow: hidden;
    img {
      width: 100%;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  &-detail {
    .value-box {
      will-change: width;
    }
    .value {
      font-family: Akrobat-Bold;
      font-weight: 800;
      font-size: 30px;
    }
    .unit {
      font-family: SourceHanSansCN-Medium;
      font-weight: 500;
      font-size: 16px;
      margin-left: 8px;
    }
    .label {
      font-weight: 400;
      font-size: 18px;
      // margin-top: 11px;
    }
  }
}
</style>
